/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PessoaView.java
 *
 * Created on 03/05/2011, 09:54:20
 */

package br.com.comprasPublicas.view.cadastro;

import br.com.comprasPublicas.dao.DAOGenerico;
import br.com.comprasPublicas.entity.Endereco;
import br.com.comprasPublicas.entity.Pessoa;
import br.com.comprasPublicas.entity.Telefone;
import br.com.comprasPublicas.util.FormatadoresUtil;
import br.com.comprasPublicas.util.HibernateUtil;
import br.com.comprasPublicas.view.pesquisa.PesquisaManutencaoPessoaView;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;

/**
 *
 * @author Rapha
 */
public class PessoaView extends javax.swing.JFrame {

    /** Creates new form PessoaView */
    public PessoaView() {
        initComponents();
        preenche_tlbTelefone();
        tblTelefone.setSelectionMode(0);
        carrega_pessoaFinal();
        btnConsultar.requestFocus();
        
        //Abaixo, método utilizado para centralizar o JFrame na tela
        Dimension tela = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation((tela.width - this.getSize().width) / 2, (tela.height - this.getSize().height) / 2);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane2 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        pnl_telefone = new javax.swing.JPanel();
        txtContato = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        txtNumeroTel = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        cmbTipoTel = new javax.swing.JComboBox();
        jScrollPane7 = new javax.swing.JScrollPane();
        tblTelefone = new javax.swing.JTable();
        jPanel3 = new javax.swing.JPanel();
        btnAdicionarTel = new javax.swing.JButton();
        btnRemoverTel = new javax.swing.JButton();
        pnlDadosEndereco = new javax.swing.JPanel();
        txtBairro = new javax.swing.JTextField();
        txtComplemtento = new javax.swing.JTextField();
        jLabel58 = new javax.swing.JLabel();
        jLabel59 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        txtCep = new javax.swing.JTextField();
        txtCidade = new javax.swing.JTextField();
        jLabel60 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        cmbEstado = new javax.swing.JComboBox();
        jLabel61 = new javax.swing.JLabel();
        jLabel57 = new javax.swing.JLabel();
        txtLogradouro = new javax.swing.JTextField();
        txtNumero = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        pnlDatosPessoa = new javax.swing.JPanel();
        txtCpfCnpj = new javax.swing.JTextField();
        txtRgInscEst = new javax.swing.JTextField();
        txtNomeRazaoSocial = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtTipo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        txtCodigo = new javax.swing.JTextField();
        jLabel39 = new javax.swing.JLabel();
        txtEmail = new javax.swing.JTextField();
        jLabel26 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        txtSite = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        txtNomeFantasia = new javax.swing.JTextField();
        ftxtDataAbertura = new javax.swing.JFormattedTextField();
        jPanel2 = new javax.swing.JPanel();
        btn_novo = new javax.swing.JButton();
        btn_excluir = new javax.swing.JButton();
        btn_salvar = new javax.swing.JButton();
        btn_cancelar = new javax.swing.JButton();
        btnConsultar = new javax.swing.JButton();
        btnVoltar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        txtObservacao = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        cmbSituacao = new javax.swing.JComboBox();
        jLabel11 = new javax.swing.JLabel();
        txtValor = new javax.swing.JTextField();

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jTable1.setName("jTable1"); // NOI18N
        jScrollPane2.setViewportView(jTable1);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N
        setResizable(false);
        setUndecorated(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowActivated(java.awt.event.WindowEvent evt) {
                formWindowActivated(evt);
            }
        });

        jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel4.setName("jPanel4"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(br.com.comprasPublicas.compraspublicas.ComprasPublicasApp.class).getContext().getResourceMap(PessoaView.class);
        jLabel1.setFont(resourceMap.getFont("jLabel1.font")); // NOI18N
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        pnl_telefone.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("pnl_telefone.border.title"))); // NOI18N
        pnl_telefone.setName("pnl_telefone"); // NOI18N

        txtContato.setName("txtContato"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        txtNumeroTel.setName("txtNumeroTel"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        cmbTipoTel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Tel", "Fax", "Tel/Fax", "Cel" }));
        cmbTipoTel.setName("cmbTipoTel"); // NOI18N

        jScrollPane7.setName("jScrollPane7"); // NOI18N

        tblTelefone.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Id", "Tipo Tel", "Número Tel", "Contato"
            }
        ));
        tblTelefone.setName("tblTelefone"); // NOI18N
        tblTelefone.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        jScrollPane7.setViewportView(tblTelefone);

        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setName("jPanel3"); // NOI18N

        btnAdicionarTel.setFont(resourceMap.getFont("btnAdicionarTel.font")); // NOI18N
        btnAdicionarTel.setMnemonic('a');
        btnAdicionarTel.setText(resourceMap.getString("btnAdicionarTel.text")); // NOI18N
        btnAdicionarTel.setName("btnAdicionarTel"); // NOI18N
        btnAdicionarTel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAdicionarTelActionPerformed(evt);
            }
        });

        btnRemoverTel.setFont(resourceMap.getFont("btnRemoverTel.font")); // NOI18N
        btnRemoverTel.setMnemonic('r');
        btnRemoverTel.setText(resourceMap.getString("btnRemoverTel.text")); // NOI18N
        btnRemoverTel.setName("btnRemoverTel"); // NOI18N
        btnRemoverTel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoverTelActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnRemoverTel, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE)
                    .addComponent(btnAdicionarTel, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnAdicionarTel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRemoverTel)
                .addContainerGap())
        );

        javax.swing.GroupLayout pnl_telefoneLayout = new javax.swing.GroupLayout(pnl_telefone);
        pnl_telefone.setLayout(pnl_telefoneLayout);
        pnl_telefoneLayout.setHorizontalGroup(
            pnl_telefoneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_telefoneLayout.createSequentialGroup()
                .addGroup(pnl_telefoneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnl_telefoneLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cmbTipoTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtNumeroTel, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtContato, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane7, 0, 0, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pnl_telefoneLayout.setVerticalGroup(
            pnl_telefoneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_telefoneLayout.createSequentialGroup()
                .addGroup(pnl_telefoneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnl_telefoneLayout.createSequentialGroup()
                        .addGroup(pnl_telefoneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(cmbTipoTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtNumeroTel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(txtContato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        pnlDadosEndereco.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("pnlDadosEndereco.border.title"))); // NOI18N
        pnlDadosEndereco.setName("pnlDadosEndereco"); // NOI18N

        txtBairro.setName("txtBairro"); // NOI18N

        txtComplemtento.setName("txtComplemtento"); // NOI18N

        jLabel58.setName("jLabel58"); // NOI18N

        jLabel59.setText(resourceMap.getString("jLabel59.text")); // NOI18N
        jLabel59.setName("jLabel59"); // NOI18N

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        txtCep.setName("txtCep"); // NOI18N

        txtCidade.setName("txtCidade"); // NOI18N

        jLabel60.setText(resourceMap.getString("jLabel60.text")); // NOI18N
        jLabel60.setName("jLabel60"); // NOI18N

        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        cmbEstado.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AC", "AL", "AM", "AP", "BA", "CE", "DF", "ES", "GO", "MA", "MG", "MS", "MT", "PA", "PB", "PE", "PI", "PR", "RJ", "RN", "RO", "RR", "RS", "SC", "SE", "SP", "TO" }));
        cmbEstado.setSelectedItem("SP");
        cmbEstado.setName("cmbEstado"); // NOI18N

        jLabel61.setText(resourceMap.getString("jLabel61.text")); // NOI18N
        jLabel61.setName("jLabel61"); // NOI18N

        jLabel57.setText(resourceMap.getString("jLabel57.text")); // NOI18N
        jLabel57.setName("jLabel57"); // NOI18N

        txtLogradouro.setName("txtLogradouro"); // NOI18N

        txtNumero.setName("txtNumero"); // NOI18N

        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        javax.swing.GroupLayout pnlDadosEnderecoLayout = new javax.swing.GroupLayout(pnlDadosEndereco);
        pnlDadosEndereco.setLayout(pnlDadosEnderecoLayout);
        pnlDadosEnderecoLayout.setHorizontalGroup(
            pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDadosEnderecoLayout.createSequentialGroup()
                .addGroup(pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel58)
                    .addGroup(pnlDadosEnderecoLayout.createSequentialGroup()
                        .addComponent(jLabel61)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtComplemtento, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pnlDadosEnderecoLayout.createSequentialGroup()
                        .addComponent(jLabel60)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCidade, javax.swing.GroupLayout.DEFAULT_SIZE, 476, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel24)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel23)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtCep, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(58, 58, 58))
            .addGroup(pnlDadosEnderecoLayout.createSequentialGroup()
                .addComponent(jLabel57)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtLogradouro, javax.swing.GroupLayout.PREFERRED_SIZE, 333, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel59)
                .addGap(8, 8, 8)
                .addComponent(txtBairro, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
                .addContainerGap())
        );
        pnlDadosEnderecoLayout.setVerticalGroup(
            pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlDadosEnderecoLayout.createSequentialGroup()
                .addGroup(pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(pnlDadosEnderecoLayout.createSequentialGroup()
                        .addGroup(pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel24)
                            .addComponent(cmbEstado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel23)
                            .addComponent(txtCep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel60)
                            .addComponent(txtCidade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel57)
                            .addComponent(txtLogradouro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14)
                            .addComponent(txtNumero, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel59)
                            .addComponent(txtBairro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(pnlDadosEnderecoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel61)
                            .addComponent(txtComplemtento, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(58, 58, 58))
                    .addComponent(jLabel58))
                .addGap(60, 60, 60))
        );

        pnlDatosPessoa.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("pnlDatosPessoa.border.title"))); // NOI18N
        pnlDatosPessoa.setName("pnlDatosPessoa"); // NOI18N

        txtCpfCnpj.setText(resourceMap.getString("txtCpfCnpj.text")); // NOI18N
        txtCpfCnpj.setName("txtCpfCnpj"); // NOI18N

        txtRgInscEst.setName("txtRgInscEst"); // NOI18N

        txtNomeRazaoSocial.setName("txtNomeRazaoSocial"); // NOI18N
        txtNomeRazaoSocial.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtNomeRazaoSocialFocusLost(evt);
            }
        });

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        txtTipo.setEditable(false);
        txtTipo.setText(resourceMap.getString("txtTipo.text")); // NOI18N
        txtTipo.setName("txtTipo"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel25.setText(resourceMap.getString("jLabel25.text")); // NOI18N
        jLabel25.setName("jLabel25"); // NOI18N

        txtCodigo.setEditable(false);
        txtCodigo.setText(resourceMap.getString("txtCodigo.text")); // NOI18N
        txtCodigo.setName("txtCodigo"); // NOI18N

        jLabel39.setText(resourceMap.getString("jLabel39.text")); // NOI18N
        jLabel39.setName("jLabel39"); // NOI18N

        txtEmail.setText(resourceMap.getString("txtEmail.text")); // NOI18N
        txtEmail.setName("txtEmail"); // NOI18N

        jLabel26.setText(resourceMap.getString("jLabel26.text")); // NOI18N
        jLabel26.setName("jLabel26"); // NOI18N

        jLabel36.setText(resourceMap.getString("jLabel36.text")); // NOI18N
        jLabel36.setName("jLabel36"); // NOI18N

        txtSite.setText(resourceMap.getString("txtSite.text")); // NOI18N
        txtSite.setName("txtSite"); // NOI18N
        txtSite.setNextFocusableComponent(txtCidade);

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        txtNomeFantasia.setName("txtNomeFantasia"); // NOI18N

        ftxtDataAbertura.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(java.text.DateFormat.getDateInstance(java.text.DateFormat.MEDIUM))));
        ftxtDataAbertura.setText(resourceMap.getString("ftxtDataAbertura.text")); // NOI18N
        ftxtDataAbertura.setName("ftxtDataAbertura"); // NOI18N

        javax.swing.GroupLayout pnlDatosPessoaLayout = new javax.swing.GroupLayout(pnlDatosPessoa);
        pnlDatosPessoa.setLayout(pnlDatosPessoaLayout);
        pnlDatosPessoaLayout.setHorizontalGroup(
            pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPessoaLayout.createSequentialGroup()
                .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnlDatosPessoaLayout.createSequentialGroup()
                        .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel9)
                            .addComponent(txtNomeRazaoSocial, javax.swing.GroupLayout.PREFERRED_SIZE, 383, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNomeFantasia, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)
                            .addComponent(jLabel5)))
                    .addGroup(pnlDatosPessoaLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtTipo, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel25)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel39)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ftxtDataAbertura, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtCpfCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, 159, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtRgInscEst, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE))
                    .addGroup(pnlDatosPessoaLayout.createSequentialGroup()
                        .addComponent(jLabel26)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, 331, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel36)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtSite, javax.swing.GroupLayout.DEFAULT_SIZE, 349, Short.MAX_VALUE)))
                .addContainerGap())
        );
        pnlDatosPessoaLayout.setVerticalGroup(
            pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnlDatosPessoaLayout.createSequentialGroup()
                .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtTipo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25)
                    .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel39)
                    .addComponent(ftxtDataAbertura, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(txtCpfCnpj, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(txtRgInscEst, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel5))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNomeRazaoSocial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNomeFantasia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(pnlDatosPessoaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel26)
                    .addComponent(txtEmail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel36)
                    .addComponent(txtSite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(33, 33, 33))
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel2.setName("jPanel2"); // NOI18N

        btn_novo.setFont(resourceMap.getFont("btn_novo.font")); // NOI18N
        btn_novo.setMnemonic('n');
        btn_novo.setText(resourceMap.getString("btn_novo.text")); // NOI18N
        btn_novo.setName("btn_novo"); // NOI18N
        btn_novo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_novoActionPerformed(evt);
            }
        });

        btn_excluir.setFont(resourceMap.getFont("btn_novo.font")); // NOI18N
        btn_excluir.setMnemonic('x');
        btn_excluir.setText(resourceMap.getString("btn_excluir.text")); // NOI18N
        btn_excluir.setName("btn_excluir"); // NOI18N
        btn_excluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_excluirActionPerformed(evt);
            }
        });

        btn_salvar.setFont(resourceMap.getFont("btn_novo.font")); // NOI18N
        btn_salvar.setMnemonic('s');
        btn_salvar.setText(resourceMap.getString("btn_salvar.text")); // NOI18N
        btn_salvar.setName("btn_salvar"); // NOI18N
        btn_salvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_salvarActionPerformed(evt);
            }
        });

        btn_cancelar.setFont(resourceMap.getFont("btn_novo.font")); // NOI18N
        btn_cancelar.setMnemonic('c');
        btn_cancelar.setText(resourceMap.getString("btn_cancelar.text")); // NOI18N
        btn_cancelar.setName("btn_cancelar"); // NOI18N
        btn_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cancelarActionPerformed(evt);
            }
        });

        btnConsultar.setFont(resourceMap.getFont("btnConsultar.font")); // NOI18N
        btnConsultar.setMnemonic('o');
        btnConsultar.setText(resourceMap.getString("btnConsultar.text")); // NOI18N
        btnConsultar.setName("btnConsultar"); // NOI18N
        btnConsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConsultarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btn_novo, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_excluir, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_salvar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btn_cancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnConsultar, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnConsultar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_novo)
                .addGap(4, 4, 4)
                .addComponent(btn_excluir)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_salvar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btn_cancelar)
                .addGap(5, 5, 5))
        );

        btnVoltar.setFont(resourceMap.getFont("btnVoltar.font")); // NOI18N
        btnVoltar.setMnemonic('v');
        btnVoltar.setText(resourceMap.getString("btnVoltar.text")); // NOI18N
        btnVoltar.setName("btnVoltar"); // NOI18N
        btnVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVoltarActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        txtObservacao.setText(resourceMap.getString("txtObservacao.text")); // NOI18N
        txtObservacao.setName("txtObservacao"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        cmbSituacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nada Consta", "Inativa", "Devedora", "Atrasos em Entrega" }));
        cmbSituacao.setName("cmbSituacao"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtObservacao, javax.swing.GroupLayout.DEFAULT_SIZE, 319, Short.MAX_VALUE)
                    .addComponent(jLabel3)
                    .addComponent(jLabel10)
                    .addComponent(cmbSituacao, 0, 319, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtObservacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cmbSituacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(46, Short.MAX_VALUE))
        );

        jLabel11.setFont(resourceMap.getFont("txtValor.font")); // NOI18N
        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        txtValor.setEditable(false);
        txtValor.setFont(resourceMap.getFont("txtValor.font")); // NOI18N
        txtValor.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtValor.setText(resourceMap.getString("txtValor.text")); // NOI18N
        txtValor.setName("txtValor"); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(pnlDatosPessoa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(pnlDadosEndereco, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(pnl_telefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 617, Short.MAX_VALUE)
                        .addComponent(btnVoltar, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(pnlDatosPessoa, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(pnlDadosEndereco, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(pnl_telefone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtValor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnVoltar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(426, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(55, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_novoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_novoActionPerformed
        status = "salvar";
        limpar_dados();
        tipo_pessoa();
        txtTipo.setText(tipoPessoa);
        ftxtDataAbertura.requestFocus();

        //preencher a data de hoje no campo data do cadastro
        Date hoje = new Date(System.currentTimeMillis());
        String formato = "dd/MM/yyyy";
        SimpleDateFormat formatter = new SimpleDateFormat(formato);
        String dataHoje = formatter.format(hoje);
        ftxtDataAbertura.setText(dataHoje);
    }//GEN-LAST:event_btn_novoActionPerformed

    private void btn_salvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_salvarActionPerformed
        //carrega_pessoa();
        if (status.equals("alterar")){
            try {
                carrega_pessoa();
                if (obj_pessoa.atualizar()){
                    carrega_endereco();
                    atualiza_endereco();
                    JOptionPane.showMessageDialog(null, "Cadastro atualizado com Sucesso!");
                }
            } catch (Exception e) {
                //JOptionPane.showMessageDialog(null, "Não foi possível completar atualização do cadastro: " +e);
            }
        }
        if (status.equals("salvar")){
            try {
                carrega_nova_pessoa();
                if (obj_pessoa.inserir()){
                    carrega_endereco();
                    inserir_endereco();
                    inserir_telefone();
                    JOptionPane.showMessageDialog(null, "Cadastro Efetuado com Sucesso!");
                    status = "atualizar";
                    preenche_objetos();
                    telefone = null;
                }
            } catch (Exception e) {
                JOptionPane.showMessageDialog(null, "Não foi possível completar o cadastro: " +e);
            }
            
        }
        

    }//GEN-LAST:event_btn_salvarActionPerformed

    private void btnAdicionarTelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAdicionarTelActionPerformed
        if (txtNumeroTel.getText().equals("")){
            JOptionPane.showMessageDialog(null, "Favor preencher o número do telefone!");
            txtNumeroTel.requestFocus();
        }
        else{
            if (status.equals("alterar")) {
                adiciona_telefone();
                preenche_telefone();
            }
            else{
                carrega_listaTelefone();
            }
        }
    }//GEN-LAST:event_btnAdicionarTelActionPerformed

    private void btnVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVoltarActionPerformed
        Object[] options = { "Sim", "Não" };
        int opcao = JOptionPane.showOptionDialog(
                null,
                "Deseja sair da tela de Fornecedor?",
                "Saída de Tela",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE,
                null,
                options,
                options[0]);

        if (opcao == 0) {
            limpar_dados();
            carrega_pessoaFinal();
            this.dispose();
        }
}//GEN-LAST:event_btnVoltarActionPerformed

    private void btnConsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultarActionPerformed
        status = "alterar";
        if (pesquisaManutencaoPessoaView == null) {
            PesquisaManutencaoPessoaView frame = new PesquisaManutencaoPessoaView(this, rootPaneCheckingEnabled);
            frame.setVisible(true);
        }
    }//GEN-LAST:event_btnConsultarActionPerformed

    private void formWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowActivated
        //Caso já tenha sido clicado em consultar, e a pessoa foi selecionada
        if (pess!=null){
            carrega_pessoaBusca();
            pess = null;
        }

    }//GEN-LAST:event_formWindowActivated

    private void btnRemoverTelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoverTelActionPerformed
        remove_telefone();
    }//GEN-LAST:event_btnRemoverTelActionPerformed

    private void btn_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cancelarActionPerformed
        limpar_dados();
        carrega_pessoaFinal();
    }//GEN-LAST:event_btn_cancelarActionPerformed

    private void btn_excluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_excluirActionPerformed
        excluir_pessoa();
        limpar_dados();
        carrega_pessoaFinal();
    }//GEN-LAST:event_btn_excluirActionPerformed

    private void txtNomeRazaoSocialFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtNomeRazaoSocialFocusLost
        txtNomeFantasia.setText(txtNomeRazaoSocial.getText());
    }//GEN-LAST:event_txtNomeRazaoSocialFocusLost

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PessoaView().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAdicionarTel;
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnRemoverTel;
    private javax.swing.JButton btnVoltar;
    private javax.swing.JButton btn_cancelar;
    private javax.swing.JButton btn_excluir;
    private javax.swing.JButton btn_novo;
    private javax.swing.JButton btn_salvar;
    private javax.swing.JComboBox cmbEstado;
    private javax.swing.JComboBox cmbSituacao;
    private javax.swing.JComboBox cmbTipoTel;
    private javax.swing.JFormattedTextField ftxtDataAbertura;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JLabel jLabel58;
    private javax.swing.JLabel jLabel59;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel60;
    private javax.swing.JLabel jLabel61;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JTable jTable1;
    private javax.swing.JPanel pnlDadosEndereco;
    private javax.swing.JPanel pnlDatosPessoa;
    private javax.swing.JPanel pnl_telefone;
    private javax.swing.JTable tblTelefone;
    private javax.swing.JTextField txtBairro;
    private javax.swing.JTextField txtCep;
    private javax.swing.JTextField txtCidade;
    private javax.swing.JTextField txtCodigo;
    private javax.swing.JTextField txtComplemtento;
    private javax.swing.JTextField txtContato;
    private javax.swing.JTextField txtCpfCnpj;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtLogradouro;
    private javax.swing.JTextField txtNomeFantasia;
    private javax.swing.JTextField txtNomeRazaoSocial;
    private javax.swing.JTextField txtNumero;
    private javax.swing.JTextField txtNumeroTel;
    private javax.swing.JTextField txtObservacao;
    private javax.swing.JTextField txtRgInscEst;
    private javax.swing.JTextField txtSite;
    private javax.swing.JTextField txtTipo;
    private javax.swing.JTextField txtValor;
    // End of variables declaration//GEN-END:variables

       public void limpar_dados()
    {
        txtTipo.setText("");
        txtCodigo.setText("");
        ftxtDataAbertura.setText("");
        txtEmail.setText("");
        txtSite.setText("");
        txtObservacao.setText("");
        txtCpfCnpj.setText("");
        txtRgInscEst.setText("");
        txtNomeRazaoSocial.setText("");
        txtObservacao.setText("");
        txtNomeFantasia.setText("");
        txtLogradouro.setText("");
        txtNumero.setText("");
        txtBairro.setText("");
        txtComplemtento.setText("");
        txtCidade.setText("");
        txtCep.setText("");
        DefaultTableModel modelo = (DefaultTableModel) tblTelefone.getModel();
        modelo.setNumRows(0);
        pessoa = null;
        endereco = null;
        telefone = null;
        obj_endereco = null;
        obj_pessoa = null;
        obj_telefone = null;
        listaTelefone = null;
        listaTelefones.clear();
    }

    public Boolean validaDados(){
        Boolean retorno = true;
        String erros = new String();

        if (ftxtDataAbertura.getText().equals("")){
            erros += "Data de abertura não informada\n";
            retorno = false;
        }

        if(txtNomeRazaoSocial.getText().equals(""))
        {
            erros += "Nome/Razão Social  não informado\n";
            retorno = false;
        }
        if(txtRgInscEst.getText().equals(""))
        {
            erros += "RG/Inscr. Estadual não informado\n";
            retorno = false;
            }

        if(txtCpfCnpj.getText().equals(""))
        {
            erros += "CPF/CNPJ não informado\n";
            retorno = false;
        }

        if(txtLogradouro.getText().equals(""))
        {
            erros += "Logradouro não informado\n";
            retorno = false;
        }

        if(txtNumero.getText().equals(""))
        {
            erros += "Número não informado\n";
            retorno = false;
        }

        if(txtBairro.getText().equals(""))
        {
            erros += "Bairro não informado\n";
            retorno = false;
        }

        if(txtCep.getText().equals(""))
        {
            erros += "CEP não informado\n";
            retorno = false;
        }

        if(txtCidade.getText().equals(""))
        {
            erros += "Cidade não informada\n";
            retorno = false;
        }

        if (!retorno){
            JOptionPane.showMessageDialog(null, "Os seguinte(s) erro(s) ocorreu(ram):\n"+erros);
        }

        return retorno;
    }

    private void carrega_pessoaBusca() {
        pessoa = new Pessoa();

        //Listando Pedido
        List<Pessoa> lista = new ArrayList ();
        lista = lista_pessoa();
        int tamanho_lista = lista.size();

        //Instanciando Pessoa selecionada
        for (int i=0; i<tamanho_lista; i++)
        {
            pessoa = lista.get(i);
        }

        pessoaBusca = pessoa.getId_pessoa();

        endereco = new Endereco();
        List<Endereco> listaEndereco = new ArrayList();
        listaEndereco = lista_endereco();
        int tamanho_endereco = listaEndereco.size();

        //Instanciando Endereco da Pessoa selecionada
        for (int i=0; i<tamanho_endereco; i++)
        {
            endereco = listaEndereco.get(i);
        }

        preenche_objetos();
    }

    private void carrega_pessoaFinal() {
        pessoa = new Pessoa();

        //Listando o ultimo pedido
        List<Pessoa> lista = new ArrayList ();
        lista = lista_ultimaPessoa();
        int tamanho_lista = lista.size();

        if(tamanho_lista>0){
            //Instanciando Pessoa selecionada
            for (int i=0; i<tamanho_lista; i++)
            {
                pessoa = lista.get(i);
            }

            pessoaBusca = pessoa.getId_pessoa();

            endereco = new Endereco();
            List<Endereco> listaEndereco = new ArrayList();
            listaEndereco = lista_endereco();
            int tamanho_endereco = listaEndereco.size();

            //Instanciando Endereco da Pessoa selecionada
            for (int i=0; i<tamanho_endereco; i++)
            {
                endereco = listaEndereco.get(i);
            }

            preenche_objetos();
        }
    }

    private List<Pessoa> lista_pessoa() {
        Session sessao = HibernateUtil.getSessao();
        Transaction transacao = sessao.beginTransaction();

        Criteria c = sessao.createCriteria(Pessoa.class);
        pessoaBusca = Integer.parseInt(pess);

        c.add(Restrictions.eq("id_pessoa", pessoaBusca));
        List lista = c.list();

        transacao.commit();
        sessao.close();

        return lista;
    }

    private void preenche_objetos() {
        txtTipo.setText(pessoa.getTipo_pessoa());
        txtCodigo.setText(String.valueOf(pessoa.getId_pessoa()));

        String formato = "dd/MM/yyyy";
        SimpleDateFormat formatter = new SimpleDateFormat(formato);
        String dataAbertura = formatter.format(pessoa.getData_abertura());
        ftxtDataAbertura.setText(dataAbertura);

        txtCpfCnpj.setText(pessoa.getCpf_cnpj());
        txtRgInscEst.setText(pessoa.getRg_inscr_est());
        txtNomeRazaoSocial.setText(pessoa.getNome_razao_soc());
        txtNomeFantasia.setText(pessoa.getNome_fantasia());
        txtEmail.setText(pessoa.getEmail());
        txtSite.setText(pessoa.getSite());
        txtObservacao.setText(pessoa.getObservacoes());
        cmbSituacao.setSelectedItem(pessoa.getSituacao());
        txtValor.setText(String.valueOf(pessoa.getTotal_gasto()));

        txtCidade.setText(endereco.getCidade());
        cmbEstado.setSelectedItem(endereco.getEstado());
        txtCep.setText(endereco.getCep());
        txtLogradouro.setText(endereco.getLogradouro());
        txtNumero.setText(endereco.getNumero());
        txtComplemtento.setText(endereco.getComplemento());
        txtBairro.setText(endereco.getBairro());

        listaTelefone = lista_telefone();

        carregar_telefones();
        
    }

    private List<Pessoa> lista_ultimaPessoa() {
        Session sessao = HibernateUtil.getSessao();
        Transaction transacao = sessao.beginTransaction();
        Criteria c = sessao.createCriteria(Pessoa.class);

        List lista = c.list();

        transacao.commit();
        sessao.close();
     
        return lista;
    }

    private void carregar_telefones() {
        DefaultTableModel modelo_tbl = (DefaultTableModel) tblTelefone.getModel();
        modelo_tbl.setNumRows(0);

        telefone = new Telefone();

        //Preechendo a tabela de Telefone
        int tamanho_lista = listaTelefone.size();
        for (int i=0; i<tamanho_lista; i++)
        {
            telefone = (Telefone) listaTelefone.get(i);
            modelo_tbl.addRow(new Object[]{telefone.getId_fone(),
                                            telefone.getTipo_fone(),
                                            telefone.getNumero_fone(),
                                            telefone.getContato_fone()
                                            });
            listaTelefones.add(telefone);
        }
    }

    private List<Telefone> lista_telefone() {
        Session sessao = HibernateUtil.getSessao();
        Transaction transacao = sessao.beginTransaction();

        //Utilizando criteria para instanciar Telefone.class
        Criteria crit = sessao.createCriteria(Telefone.class).createAlias("pessoa", "p");

        pessoaBusca = pessoa.getId_pessoa();
        //Buscando conforme restrição
        crit.add(Restrictions.eq("p.id_pessoa", pessoaBusca));
        List lista = crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();

        transacao.commit();
        sessao.close();

        return lista;
    }

    private void adiciona_telefone() {
        telefone = new Telefone();

        telefone.setTipo_fone(cmbTipoTel.getSelectedItem().toString());
        telefone.setNumero_fone(txtNumeroTel.getText());
        telefone.setPessoa(pessoa);
        telefone.setContato_fone(txtContato.getText());

        limpa_obj_telefone();

        listaTelefones.add(telefone);

        obj_telefone = new DAOGenerico(telefone);

        atualiza_telefone_pessoa();
    }

    private void limpa_obj_telefone() {
        cmbTipoTel.setSelectedIndex(0);
        txtNumeroTel.setText("");
        txtContato.setText("");
    }

    private void preenche_telefone() {
        DefaultTableModel modelo_tbl = (DefaultTableModel) tblTelefone.getModel();
        modelo_tbl.addRow(new Object[]{telefone.getId_fone(),
                                        telefone.getTipo_fone(),
                                        telefone.getNumero_fone(),
                                        telefone.getContato_fone()
                                        });
    }

    private void atualiza_telefone_pessoa() {
        try{
            obj_telefone.inserir();
        }
        catch(Exception e){
            JOptionPane.showMessageDialog(null, "Telefone Não pôde ser inserido: " +e);
        }
        obj_telefone = null;

    }

    private void remove_telefone() {
        if (tblTelefone.getSelectedRow()==-1){
            JOptionPane.showMessageDialog(null, "Nenhum Telefone Selecionado");
        }
        else{
            Integer index = tblTelefone.getSelectedRow();

            pega_objetoExcuir();

            if (index >= 0) {
                obj_telefone = new DAOGenerico(telefone);

                if(obj_telefone.excluir()){
                    //removendo o item selecionado na tabela da listaTelefones
                    int selecao_item_apagar = tblTelefone.getSelectedRow();
                    listaTelefones.remove(selecao_item_apagar);

                    JOptionPane.showMessageDialog(null, "Removeu");
                    DefaultTableModel modelo_tbl = (DefaultTableModel) tblTelefone.getModel();
                    modelo_tbl.removeRow(tblTelefone.getSelectedRow());
                }
                else{
                    JOptionPane.showMessageDialog(null, "Telefone não foi excluído!");
                }
                obj_telefone = null;
            }
        }
    }

    private void pega_objetoExcuir() {
        //Setar o Objeto telefone selecionado
        List<Telefone> lista = new ArrayList ();
        lista = item_telefone_tabela();
        int tamanho_lista = lista.size();
        for (int i=0; i<tamanho_lista; i++)
        {
            telefone = lista.get(i);
        }
        telefone.setPessoa(null);

        obj_telefone = new DAOGenerico(telefone);
        obj_telefone.atualizar();

    }

    private List<Telefone> item_telefone_tabela() {
        Session sessao = HibernateUtil.getSessao();
        Transaction transacao = sessao.beginTransaction();
        Query query = sessao.createQuery("from Telefone where id_fone = :id_fone");
        query.setInteger("id_fone", Integer.parseInt(tblTelefone.getModel().getValueAt(tblTelefone.getSelectedRow(),0).toString()));

        List list = query.list();

        transacao.commit();
        sessao.close();

        return list;
    }

    

    private void excluir_pessoa() {
        Object[] options = { "Sim", "Não" };
        int opcao = JOptionPane.showOptionDialog(
                null,
                "Deseja Excluir Fornecedor?",
                "Exclusão de Fornecedor",
                JOptionPane.DEFAULT_OPTION,
                JOptionPane.WARNING_MESSAGE,
                null,
                options,
                options[0]);

        if (opcao == 0) {
            obj_pessoa = new DAOGenerico(pessoa);
            try{
                obj_pessoa.excluir();
                JOptionPane.showMessageDialog(null, "Fornecedor Excluído com sucesso!");
            }catch(Exception e){
                JOptionPane.showMessageDialog(null, "Fornecedor não pôde ser Excluido: " +e);
            }
            obj_pessoa = null;
        }
    }

    private void carrega_pessoa() {
        if (status.equals("alterar")){
            int id = Integer.parseInt(txtCodigo.getText());
            pessoa.setId_pessoa(id);
        }
        
        pessoa.setCpf_cnpj(txtCpfCnpj.getText());
        
        Date dataPedido = FormatadoresUtil.data2Banco(ftxtDataAbertura.getText());
        pessoa.setData_abertura(dataPedido);
        if (!txtEmail.getText().equals("")){
            pessoa.setEmail(txtEmail.getText());
        }
        
        if (!txtNomeFantasia.getText().equals("")){
            pessoa.setNome_fantasia(txtNomeFantasia.getText());
        }
        pessoa.setNome_razao_soc(txtNomeRazaoSocial.getText());
        pessoa.setObservacoes(txtObservacao.getText());
        pessoa.setRg_inscr_est(txtRgInscEst.getText());
        if (!txtSite.getText().equals("")){
            pessoa.setSite(txtSite.getText());
        }
        String situcao = cmbSituacao.getSelectedItem().toString();
        pessoa.setSituacao(situcao);
                 
        obj_pessoa = new DAOGenerico(pessoa);
    }

    private List<Endereco> lista_endereco() {
        Session sessao = HibernateUtil.getSessao();
        Transaction transacao = sessao.beginTransaction();

        //Utilizando criteria para instanciar Telefone.class
        Criteria crit = sessao.createCriteria(Endereco.class).createAlias("pessoa", "p");

        //Buscando conforme restrição
        crit.add(Restrictions.eq("p.id_pessoa", pessoaBusca));
        List lista = crit.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();

        transacao.commit();
        sessao.close();

        return lista;
    }

    private void atualiza_endereco() {
        obj_endereco.atualizar();
    }

    private void carrega_endereco() {
        endereco = new Endereco();

        if (status.equals("alterar")) {
            //Listando o endereco conforme a pessoa selecionada
            List<Endereco> lista = new ArrayList();
            lista = lista_endereco();
            int tamanho_lista = lista.size();

            //Instanciando Endereco selecionado
            for (int i = 0; i < tamanho_lista; i++) {
                endereco = lista.get(i);
            }
        }
        else endereco.setPessoa(pessoa);

        endereco.setBairro(txtBairro.getText());
        endereco.setCep(txtCep.getText());
        endereco.setCidade(txtCidade.getText());
        endereco.setComplemento(txtComplemtento.getText());
        String estado = cmbEstado.getSelectedItem().toString();
        endereco.setEstado(estado);
        endereco.setLogradouro(txtLogradouro.getText());
        endereco.setNumero(txtNumero.getText());

        obj_endereco = new DAOGenerico(endereco);
    }

    private void inserir_pessoa() {
        try {
            obj_pessoa.inserir();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nao foi possivel inserir pessoa: " +e);
        }
    }

    private void inserir_endereco() {
        obj_endereco.inserir();
    }

    private void carrega_listaTelefone() {
        telefone = new Telefone();

        telefone.setTipo_fone(cmbTipoTel.getSelectedItem().toString());
        telefone.setNumero_fone(txtNumeroTel.getText());
        //telefone.setPessoa(pessoa);
        telefone.setContato_fone(txtContato.getText());

        limpa_obj_telefone();

        listaTelefones.add(telefone);
        DefaultTableModel modelo_tbl = (DefaultTableModel) tblTelefone.getModel();
        modelo_tbl.addRow(new Object[]{telefone.getId_fone(),
                                        telefone.getTipo_fone(),
                                        telefone.getNumero_fone(),
                                        telefone.getContato_fone()
                                        });
    }

    private void inserir_telefone() {
        int tam_listaTelefone = listaTelefones.size();
        for(int i=0;i<tam_listaTelefone;i++){
            telefone = listaTelefones.get(i);
            telefone.setPessoa(pessoa);
            obj_telefone = new DAOGenerico(telefone);

            obj_telefone.inserir();
        }
    }

    

    private void tipo_pessoa() {
        Object[] options = { "Fisica", "Jurídica" };
        int opcao = JOptionPane.showOptionDialog(
            null,
            "Escolha tipo de Pessoa:",
            "Tipo Pessoa",
        JOptionPane.DEFAULT_OPTION,
        JOptionPane.WARNING_MESSAGE,
            null,
            options,
            options[0]);

        if (opcao == 0) {
            tipoPessoa = "F";
        }
        else if (opcao== 1){
            tipoPessoa = "J";
        }
        else btn_cancelar.doClick();
    }

    private void carrega_nova_pessoa() {
        Date dataPedido = FormatadoresUtil.data2Banco(ftxtDataAbertura.getText());

        pessoa = new Pessoa();
        pessoa.setCpf_cnpj(txtCpfCnpj.getText());
        pessoa.setData_abertura(dataPedido);
        pessoa.setEmail(txtEmail.getText());
        pessoa.setNome_fantasia(txtNomeFantasia.getText());
        pessoa.setNome_razao_soc(txtNomeRazaoSocial.getText());
        pessoa.setObservacoes(txtObservacao.getText());
        pessoa.setRg_inscr_est(txtRgInscEst.getText());
        pessoa.setSite(txtSite.getText());
        pessoa.setSituacao(cmbSituacao.getSelectedItem().toString());
        pessoa.setTipo_pessoa(txtTipo.getText());
        pessoa.setTotal_gasto(0.0);

        obj_pessoa = new DAOGenerico(pessoa);
    }

    private void atualiza_tabela_telefone() {
        int tamanho_listaTelefone = listaTelefones.size();
        for (int i=0;i>tamanho_listaTelefone;i++){
            telefone = listaTelefones.get(i);
            JOptionPane.showMessageDialog(null, i+" Vez(es)");
            DefaultTableModel modelo_tbl = (DefaultTableModel) tblTelefone.getModel();
            modelo_tbl.addRow(new Object[]{telefone.getId_fone(),
                                            telefone.getTipo_fone(),
                                            telefone.getNumero_fone(),
                                            telefone.getContato_fone()
                                            });
        }
    }

    private void preenche_tlbTelefone() {
        tblTelefone.getColumnModel().getColumn(0).setPreferredWidth(0);
        tblTelefone.getColumnModel().getColumn(1).setPreferredWidth(50);
        tblTelefone.getColumnModel().getColumn(2).setPreferredWidth(100);
        tblTelefone.getColumnModel().getColumn(3).setPreferredWidth(200);
    }

    private Endereco endereco;
    private Telefone telefone;
    private Pessoa pessoa;
    private Pessoa pessoaUlt;
    private String status = "alterar";
    private DAOGenerico obj_pessoa;
    public static String pess = null;
    private PesquisaManutencaoPessoaView pesquisaManutencaoPessoaView;
    private int pessoaBusca;
    private List<Telefone> listaTelefone = new ArrayList();
    private List<Telefone> listaTelefones = new ArrayList<Telefone>();
    private DAOGenerico obj_telefone;
    private DAOGenerico obj_endereco;
    private String tipoPessoa;

}
